package com.zdy.reflection;
import java.lang.Class;
/**
 * Created by 逸足天涯
 * on 3/5/2020.
 */
//什么叫做反射
public class Test02 extends Object{
    public static void main(String[] args) throws ClassNotFoundException {
        //通过反射获取类的Class 对象。
        //Class 描述类的类。
        Class c1 = Class.forName("com.zdy.reflection.User");
      
        System.out.println(c1);
        Class c2 = Class.forName("com.zdy.reflection.User");
        Class c3 = Class.forName("com.zdy.reflection.User");
        Class c4 = Class.forName("com.zdy.reflection.User");
        //一个(User)类在内存中只有一个Class （类型的）对象，
        //一个类被加载后整个，类的整个结构都会封装在Class 中去。
        System.out.println(c1.getName());
 



        System.out.println(c1.hashCode());
        System.out.println(c2.hashCode());
        System.out.println(c3.hashCode());
        System.out.println(c4.hashCode());
    }
}

//实体类
class User{
    private int id;
    private String name;
    private int age;
    private void test(){}
    public User() {
    }

    public User(int id, String name, int age) {
        this.id = id;
        this.name = name;
        this.age = age;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}
